package kr.co.doriclassic.forloop;

public class Sum2 {
	int sCount;
	private String inpNum ;
	private String[] sNum;
	private int sum=0;	
	
	public Sum2(String inpNum) {
		this.inpNum = inpNum;
	}
	
	public int sumCount(){
		sNum = inpNum.split(" ");
		sCount = Integer.parseInt(sNum[0]);
		for(int i=1;i<=sCount;i++){
			System.out.print(sNum[i]+ " ");
			sum+=Integer.parseInt(sNum[i]);
		}
		return sum;
	}

	@Override
	public String toString() {
		return "의 합은" + sumCount() + "입니다.";
	}
	
}
